import request from '@/utils/request.js'

export function login(data) {
    return request({
        url: '/api/auth/login',
        method: 'post',
        params: data,
    })
}
export function deleteLogin(token) {
    return request({
        url: '/api/auth/logout',
        method: 'DELETE',
        headers: {
            Authorization: `Bearer ${token}`,
        },
    })
}
export function Userpassword(data, userId) {
    return request({
        url: `/api/users/${userId}/password`,
        method: 'put',
        data
    })
}
export function password(data, userId) {
    return request({
        url: `/api/users/${userId}/self_password`,
        method: 'put',
        data
    })
}
// 菜单下拉列表
export function databar(data) {
    return request({
        url: '/api/menus/options',
        method: 'get',
        params: data,
    })
}
//users
export function listUser(data) {
    return request({
        url: '/api/users/page',
        method: 'get',
        params: data,
    })
}
export function changeUserStatus(data, id) {
    return request({
        url: `/api/users/${id}/status`,
        method: 'put',
        data
    })
}

export function delUser(data) {
    return request({
        url: `/api/users/${data}`,
        method: 'delete',

    })
}

export function informationName(data) {
    return request({
        url: `api/users/me`,
        method: 'get',
        headers: {
            Authorization: `Bearer ${data}`, // 将 token 添加到请求头
        },
    })
}
export function rolesOptions(data) {
    return request({
        url: '/api/roles/options',
        method: 'get',
        headers: {
            Authorization: `Bearer ${data}`, // 将 token 添加到请求头
        },
    })
}
//修改用户当前条数据
export function Currentdata(userId) {
    return request({
        url: `/api/users/${userId}/form`,
        method: 'get',
    })
}

//addUser, updateUser, getUser
export function addUser(data) {
    return request({
        url: '/api/users',
        method: 'post',
        data,
    })
}
export function updateUser(data) {
    return request({
        url: `/api/users/${data.id}`,
        method: 'put',
        data,
    })
}

export function getUser(data) {
    return request({
        url: `/api/users/${data}/form`,
        method: 'get'
    })
}

